package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.mapper.ClearOrderMapper;
import com.itheima.service.ClearOrderService;
import com.itheima.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Calendar;
import java.util.Date;

@Service(interfaceClass = ClearOrderService.class)
public class ClearOrderServiceImpl implements ClearOrderService {
    @Autowired
    private ClearOrderMapper clearOrderMapper;

    @Override
    public void deleteOrder() throws Exception {
        Calendar calendar = Calendar.getInstance();
        //获取当前日期
        Date time = calendar.getTime();
        //获取过去12个月的数据 2019-03
        String month = DateUtils.parseDate2String(time, "yyyy-MM");
        String dateEnd = month + "-31";
        clearOrderMapper.deleteOrder(dateEnd);
    }
}
